package com.itheima.sh.esdemo.Controller;

import com.itheima.sh.esdemo.pojo.Goods;
import com.itheima.sh.esdemo.service.GoodsService;
import org.elasticsearch.client.RestHighLevelClient;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * @author ：qcq
 * @date ：Created in 2020/11/23 22:53
 * @description：
 */

public class GoodsController {
    private RestHighLevelClient client;

    /* @Before
     public void BeforeClient() {
         client = new RestHighLevelClient(
                 RestClient.builder(new HttpHost(
                                 "192.168.200.150", 9200, "http"
                         )
                 )
         );
     }*/






    /*@Test
    public void testBulkAddDocumentList() throws Exception {
        // 1.从数据库查询文档数据
        //第一步：准备数据源。本案例使用List来模拟数据源。

        // 2.创建BulkRequest对象
        BulkRequest bulkRequest = new BulkRequest();
        // 3.创建多个IndexRequest对象，并添加到BulkRequest中
        for (User user : users) {
            bulkRequest.add(new IndexRequest("user")
                    .id(user.getId().toString())
                    .source(JSON.toJSONString(user), XContentType.JSON)
            );
        }
        // 4.发起请求
        BulkResponse bulkResponse = client.bulk(bulkRequest, RequestOptions.DEFAULT);

        System.out.println("status: " + bulkResponse.status());
    }*/


  /*  @After
    public void AfterClient() throws Exception {
        client.close();
    }*/
}
